#version 300 es
precision mediump float;
uniform sampler2D sTexture;
uniform highp mat4 uVPMatrix;

in vec2 vTextureCoord;
in vec4 vambient;
in vec4 vdiffuse;
in vec4 vspecular;
in vec4 vPosition;

out vec4 fragColor;
void main()                         
{
      vec4 gytyPosition=uVPMatrix * vec4(vPosition.xyz,1);
         gytyPosition=gytyPosition/gytyPosition.w;
         float s=gytyPosition.s+0.5;
         float t=gytyPosition.t+0.5;
         vec4 finalColor=vec4(0.8,0.8,0.8,1.0);
         if(s>=0.0&&s<=1.0&&t>=0.0&&t<=1.0){
         vec4 projColor=texture(sTexture,vec2(s,t));
         vec4 specularTemp=projColor*vspecular;
         vec4 diffuseTemp=projColor*vdiffuse;
            fragColor=finalColor*vambient+finalColor*specularTemp+finalColor*diffuseTemp;
         }else {
             fragColor = finalColor*vambient+finalColor*vspecular+finalColor*vdiffuse;
          }


}              